package com.创建型模式.原型模式;

/**
 * 原型模式
 */
public class Prototype implements Cloneable{
    Prototype(){
        System.out.println("克隆成功");
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        System.out.println("原型克隆成功");
        return (Prototype)super.clone();
    }

    public static void main(String[] args) throws Exception {
        Prototype p1 = new Prototype();
        Prototype p2 = (Prototype) p1.clone();
        System.out.println(String.format("p1=p2:%s",p1==p2));
    }
}
